﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UITesting.cs" company="">
//   
// </copyright>
// <summary>
//   The ui testing.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace UITest.SeleniumTestProject
{
    using System;

    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using OpenQA.Selenium;

    using UITest.Selenium.SeleniumControls.HtmlControls;

    /// <summary>
    ///     The ui testing.
    /// </summary>
    [CodedUITest]
    public class UITesting : UITestingBaseClass
    {
        #region Public Properties

        /// <summary>
        ///     Gets or sets the test context which provides
        ///     information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        ///     The click test method.
        /// </summary>
        [TestCategory("SeleniumTest")]
        [TestMethod]
        public void ClickTestMethod()
        {
            this.LaunchTestingPage();

            var seleiumButton = new SeleniumButton(this.Selenium, "Simple Button");

            seleiumButton.Click();
            this.Selenium.Report.WriteTestOutput("Click on Simple Button");
        }

        /// <summary>
        ///     The find element test method.
        /// </summary>
        [TestCategory("SeleniumTest")]
        [TestMethod]
        public void FindElementTestMethod()
        {
            this.LaunchTestingPage();

            var control = new SeleniumEdit(this.Selenium, By.CssSelector("[name='text1_test']"));
            control.FindElement().SendKeys("abc");
        }

        /// <summary>
        ///     The find elements test method.
        /// </summary>
        [TestCategory("SeleniumTest")]
        [TestMethod]
        public void FindElementsTestMethod()
        {
            this.LaunchTestingPage();

            var control = new SeleniumEdit(this.Selenium, By.CssSelector("[name='text1_test']"));
            Console.WriteLine(control.FindElements().Count);
        }

        /// <summary>
        ///     The selenium edit test method.
        /// </summary>
        [TestCategory("SeleniumTest")]
        [TestMethod]
        public void SeleniumEditTestMethod()
        {
            this.LaunchTestingPage();

            var control = new SeleniumEdit(this.Selenium, By.CssSelector("[name='text1_test']"));
            control.SetText("abc");
        }

        #endregion
    }
}